package com.zyd.blog.personal.controller;

import com.zyd.blog.personal.service.BigPlotformService;
import com.zyd.blog.personal.utils.RespResultUtils;
import com.zyd.blog.personal.vo.MerchantInfoVo;
import com.zyd.blog.personal.vo.ResponseResultVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 商家合作
 * @author mfy
 */
@RestController
@RequestMapping("/plotform")
public class MerchantController {

    @Resource
    private BigPlotformService bigPlotformService;

    /**
     * 商家合作签约申请
     * 访问路径 http://localhost:8443/plotform/applyMerchant
     * @param merchantInfoVo    商家信息
     * @return  签约申请结果
     */
    @RequestMapping("/applyMerchant")
    public ResponseResultVo applyMerchant(MerchantInfoVo merchantInfoVo){
        if(merchantInfoVo == null){
            return RespResultUtils.getFailResult("无商家信息");
        }
        if(bigPlotformService.applyMerchant(merchantInfoVo)){
            return RespResultUtils.getSuccessBoolean("申请提交成功");
        }else{
            return RespResultUtils.getFailResult("申请提交失败");
        }
    }

    /**
     * 得到合作商家信息
     * 访问路径 http://localhost:8443/plotform/getMerchantInfo?id=1
     * @param id    合作商家id
     * @return  商家信息
     */
    @RequestMapping("/getMerchantInfo")
    public ResponseResultVo getMerchantInfo(Long id ){
        if(id == null){
            return RespResultUtils.getFailResult("合作商家id不能为空");
        }
        return RespResultUtils.getSuccessData(bigPlotformService.getMerchantInfo(id));
    }


}
